#pragma once

template <class DT>
class DNode
{
	DT data;
	DNode* prior, * next; //pointers
};

template <class DT>
class DoubleLinkedList
{
private:
	DNode<DT> * Initptr;
	int m_Length;//the number of DNode
public:
	DoubleLinkedList();//constructor, initialization without DNode
	~DoubleLinkedList();//destructor
	//iterator
	class iterator
	{
		DNode<DT>* ptr;//mark the position of the pointer
		iterator(DNode<DT>* x):ptr(x){}
		iterator():ptr(nullptr){}
		DT& operator*()const {
			return ptr->data;
		}
		bool operator!=(iterator x) {
			if (ptr == x->ptr)
				return 0;
			else
				return 1;
		}
		iterator& operator++() {
			ptr = ptr->next;
			return *this;
		}
		iterator& operator++(int) {
			iterator old = *this;
			++(*this);
			return old;
		}
		iterator& operator--() {
			ptr = ptr->prior;
			return *this;
		}
		iterator& operator--(int) {
			iterator old = *this;
			--(*this);
			return old;
		}
	};

	iterator insert(DT x, iterator pos);//insert a data into the position
	iterator find(DoubleLinkedList& _List, DT& _val);
	void push_back();//add node to the end

};

